home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / utils / config.el.z / config.el
Encoding:
Text File  |  1998-05-21  |  2.2 KB  |  71 lines

  1. ;;; config.el --- access configuration parameters
  2.  
  3. ;; Copyright (C) 1997 Sun Microsystems, Inc.
  4.  
  5. ;; Author:   Martin Buchholz
  6. ;; Keywords: configure
  7.  
  8. ;; This file is part of XEmacs.
  9.  
  10. ;; XEmacs is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; XEmacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with XEmacs; see the file COPYING.  If not, write to the
  22. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. ;; Boston, MA 02111-1307, USA.
  24.  
  25. ;;; Synched up with: not in FSF.
  26.  
  27. ;;; Commentary:
  28.  
  29. ;;; Code:
  30.  
  31.  
  32. (defvar config-value-file (expand-file-name "config.values" exec-directory)
  33.   "File containing configuration parameters and their values.")
  34.  
  35. (defvar config-value-hash-table nil
  36.   "Hashtable to store configuration parameters and their values.")
  37.  
  38. ;;;###autoload
  39. (defun config-value-hash-table ()
  40.   "Returns hashtable of configuration parameters and their values."
  41.   (when (null config-value-hash-table)
  42.     (setq config-value-hash-table (make-hashtable 300))
  43.     (save-excursion
  44.       (let ((buf (get-buffer-create " *Config*")))
  45.     (set-buffer buf)
  46.     (erase-buffer)
  47.     (insert-file-contents config-value-file)
  48.     (goto-char (point-min))
  49.     (condition-case nil
  50.         (while t
  51.           (let* ((key (read buf))
  52.              (value (read buf))
  53.              (prev (gethash key config-value-hash-table)))
  54.         (cond ((null prev)
  55.                (puthash key value config-value-hash-table))
  56.               ((atom prev)
  57.                (puthash key (list prev value) config-value-hash-table))
  58.               (t
  59.                (nconc prev (list value))))))
  60.       (end-of-file nil)))
  61.       (kill-buffer " *Config*")))
  62.   config-value-hash-table)
  63.  
  64. ;;;###autoload
  65. (defun config-value (config-symbol)
  66.   "Return the value of the configuration parameter CONFIG_SYMBOL."
  67.   (gethash config-symbol (config-value-hash-table)))
  68.       
  69. (provide 'config)
  70. ;;; config.el ends here
  71.